/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.event.thuoc;

import gui.thuoc.ThuocChiTiet_Dialog;
import gui.thuoc.ThuocSuaThongTin_Full;
import java.awt.print.PrinterException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import model.dao.thuoc.ThuocDAO;

/**
 *
 * @author nv_ca@live.com
 */
public class ThuocTimKiemDlg_evt {

    public static final void btnTimKiemActionPerformed(int option, JTextField textField) {
        //TODO Tổng hợp điều kiện và query, sau đó hiển thị lên table

        JOptionPane.showMessageDialog(null, "Found");
    }

    public static final void btnSuaActionPerformed(JTable jTable) {
        int thuocMa = (int) jTable.getValueAt(jTable.getSelectedRow(), 0);
        ThuocSuaThongTin_Full thuocSuaThongTin_Full = new ThuocSuaThongTin_Full(null, true, ThuocDAO.loadByThuocID(thuocMa).get(0));
        thuocSuaThongTin_Full.setLocationRelativeTo(null);
        thuocSuaThongTin_Full.setVisible(true);
    }

    public static final void btnChiTietActionPerformed(JTable jTable) {
        int thuocMa = (int) jTable.getValueAt(jTable.getSelectedRow(), 0);
        ThuocChiTiet_Dialog thuocChiTiet_Dialog = new ThuocChiTiet_Dialog(null, true, ThuocDAO.loadByThuocID(thuocMa).get(0));
        thuocChiTiet_Dialog.setLocationRelativeTo(null);
        thuocChiTiet_Dialog.setVisible(true);
    }

    public static final void btnInActionPerformed(JTable table) {
        try {
            table.print();
        } catch (PrinterException ex) {
            Logger.getLogger(ThuocTimKiemDlg_evt.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static final void btnCloseActionPerformed(JDialog dlg) {
        dlg.dispose();
    }
}
